package net.arvin.mobilebanksystem.activity;

import java.util.Timer;
import java.util.TimerTask;

import net.arvin.mobilebanksystem.R;
import net.arvin.utils.PreferenceUtils;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.Window;

public class SplashActivity extends Activity {

	@SuppressWarnings("rawtypes")
	private Class type; 
	
	private Timer timer;
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		requestWindowFeature(Window.FEATURE_NO_TITLE);
		setContentView(R.layout.activity_splash);
		String token = PreferenceUtils.getPreferToken(this);
		timer = new Timer();
		type = null;
		if(token != null && token.equals("token")){
			type = MainActivity.class;
		}else{
			type = UserInfoActivity.class;
		}
		timer.schedule(new TimerTask() {
			@Override
			public void run() {	
				timer.cancel();
				Intent tent = new Intent();
				tent.setClass(SplashActivity.this, type);
				startActivity(tent);
				SplashActivity.this.finish();
			}
		}, 1000, 1000);
	}
}
